void SetUpThreads()
{

    if(g_bMultiThread && !g_bThreadsInitialized)
    {
        for(int i=0;i<g_dwNumberofRecordThreads;i++)
        {
            //create record semiphore per thread
            if(g_RenderRecordSem[i])
                CloseHandle( g_RenderRecordSem[i] );
            g_RenderRecordSem[i] = CreateSemaphore(NULL, 0, 1, NULL);
            
            //create playback semiphore per thread
            if(g_RenderPlaybackSem[i])
                CloseHandle( g_RenderPlaybackSem[i] );
            g_RenderPlaybackSem[i] = CreateSemaphore(NULL, 0, 1, NULL);
           
            //create record thread
            if(g_RecordThreads[i])
                CloseHandle( g_RecordThreads[i] );
            g_RecordThreads[i] = CreateThread(NULL, 0, RenderThreadProc, (LPVOID)i, 0, &g_ThreadIds[i]);
        }

        g_bThreadsInitialized = true;
        g_DoRender = false;
    }
}
